<template>
  <div class="refine_userlist">
    <h2 class="titleblue">VTS分中心列表</h2>
    <div class="contant">
      <data-table :page='currentPage' :head="thead" :data="tableData"></data-table>
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page.sync="currentPage"
        layout="total,prev, pager, next, jumper"
        :total="dataCount"
        background
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
  import DataTable from '@/components/common/DataTable.vue'
  import vtsSubCenterService from '@/services/VtsSubCenterService'

  export default {
    components: {
      'data-table': DataTable
    },
    data: function () {
      return {
        thead: [
          {name: 'VTS中心名称', prop: 'name'},
          {name: '位置', prop: 'position'},
          {name: '建成时间', prop: 'createFinishTime'},
          {name: '纬度', prop: 'latitude'},
          {name: '经度', prop: 'longitude'},
        ],
        tableData: [],
        currentPage: 1,
        currentPages: 1,
        dataCount: 0
      }
    },
    created () {
      this.getAll();
    },methods: {
      async getAll () {
        let resp = await vtsSubCenterService.searchData(this.currentPage-1)
        this.dataCount = resp.dataCount
        let temptabledate=resp.data
        if (temptabledate!=null){
          for (let k=0;k<temptabledate.length;k++){
            let temptime=temptabledate[k].createFinishTime;
            temptime=temptime.replace('T',' ');
            temptime=temptime.replace('Z',' ');
            temptime=temptime.replace('00:00:00','');
            temptabledate[k].createFinishTime=temptime;
          }
        }
        this.tableData = temptabledate
      },
      handleCurrentChange (val) {
        this.currentPage = val
        this.getAll()
      },
    }
  }
</script>

<style lang='scss'>
  .refine_userlist {
    width: 100%;
    display: inline-block;

    .inlanselect {
      float: left;
      margin-right: 10px;
    }

    .el-tabs {
      width: 100%;
      margin-top: 20px;
      display: inline-block;
    }

    .el-table tr:nth-child(2n) {
      background: #FAFAFA
    }

    .table {
      margin-top: 20px;
    }

    .user-title {
      width: 100%;
      display: inline-block;
    }
  }
</style>
